package com.monlyu.bean;

import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.math.NumberUtils;

import com.monlyu.util.StringUtil;

/**
 * 验证码的Bean
 * 
 * @author monlyu
 */
public class AuthCodeBean {

	/**
	 * 验证码的长度
	 */
	private int length;
	/**
	 * 如果有字母,忽略大小写
	 */
	private boolean ignoreCase;

	/** 文字类型 */
	private String type;

	private boolean needLines;

	private boolean active;

	public boolean isActive() {
		return active;
	}

	public void setActive(String value) {
		setActive(BooleanUtils.toBoolean(value));
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public boolean isNeedLines() {
		return needLines;
	}

	public void setNeedLines(boolean needLines) {
		this.needLines = needLines;
	}

	public void setNeedLines(String needLines) {
		setNeedLines(BooleanUtils.toBoolean(needLines));
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public void setLength(String length) {
		setLength(NumberUtils.toInt(length, 4));
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		if (StringUtil.isTrimEmpty(type) || type.length() < 3) {
			type = "001";
		}
		this.type = type;
	}

	public boolean isIgnoreCase() {
		return ignoreCase;
	}

	public void setIgnoreCase(boolean ignoreCase) {
		this.ignoreCase = ignoreCase;
	}

	public void setIgnoreCase(String value) {
		setIgnoreCase(BooleanUtils.toBoolean(value));
	}
}
